/*
 * Filename    : State_Game_Pause.java
 * Projectname : RamaShinta
 * Date        : Nov 25, 2012 , 10:41:06 AM 
 * 
 */

package com.amikomgamedev.ramashinta.state;

import org.andengine.entity.scene.ITouchArea;
import org.andengine.entity.scene.Scene;
import org.andengine.input.touch.TouchEvent;

import com.amikomgamedev.ramashinta.ServerData;
import com.amikomgamedev.ramashinta.Utils;

import android.view.KeyEvent;

public class State_Game_Pause extends State_Game_Over
{
	Scene	pauseScene;

	protected void create_State_Game_Pause()
	{
		// akhir setelah di load..
		pauseScene = new Scene();
		graphic.attachMenuPause(pauseScene);
		graphic.attachPauseContinue(pauseScene);
		graphic.attachPauseRestart(pauseScene);
		graphic.attachPauseMainMenu(pauseScene);
		pauseScene.setBackgroundEnabled(false);
		
		m_Scene.setChildScene(pauseScene);
//		pauseGame();
	}

//	private void pauseGame()
//	{
//		// TODO Auto-generated method stub
//		if (mEngine.isRunning())
//		{
//			mEngine.stop();
//
//		} else
//		{
//			mEngine.start();
//
//		}
//
//	}

	
	
	@Override
	public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX,
			float pTouchAreaLocalY)
	{
		if (State_Menu_Current == STATE_GAME_PAUSE)
		{
			
			if (pSceneTouchEvent.isActionDown() || pSceneTouchEvent.isActionMove())
			{
				Utils.TRACE("aaaaaaaaaaaaaaaaaaaa");
			 if (pTouchArea.equals(graphic.spr_Pause_Btn_Continue))
			{
				 Utils.TRACE("klik continue");
				 sound.playGameplayBGM();
				 m_Scene.clearChildScene();
					graphic.detachMenuPause();
					State_Menu_Current = STATE_GAME_PLAY;
					mEngine.start();
			}
			 
			 if (pTouchArea.equals(graphic.spr_Pause_Btn_Restart))
				{
				 m_Scene.clearChildScene();
					graphic.detachMenuPause();
					graphic.detachGameplay();
					switchState(STATE_GAME_PLAY);
					mEngine.start();
				}
			 
			 if (pTouchArea.equals(graphic.spr_Pause_Btn_MainMenu))
				{
				 m_Scene.clearChildScene();
					graphic.detachMenuPause();
					graphic.detachGameplay();
					switchState(STATE_MENU_MAIN);
					mEngine.start();
				}
			}
		
		}

		return super.onAreaTouched(pSceneTouchEvent, pTouchArea, pTouchAreaLocalX, pTouchAreaLocalY);
	}
}
